﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;

public partial class MRP_ViewOrderBill : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Database db = DatabaseFactory.CreateDatabase("MRPSqlServer");
            string sSQL = ("SELECT ID, CustomerCode+'('+CompanyName+')' as CustomerName  FROM MRP_Customer Order By CustomerCode");
            DataSet ds = db.ExecuteDataSet(CommandType.Text, sSQL);

            DropDownList1.DataSource = ds.Tables[0].DefaultView;
            DropDownList1.DataTextField = "CustomerName";
            DropDownList1.DataValueField = "ID";
            DropDownList1.DataBind();
            //Database db = DatabaseFactory.CreateDatabase("MRPSqlServer");
            //string sSQL = "SELECT MRP_MaterialMain.ID,MRP_MaterialMain.MCode, MRP_MaterialMain.Name, MRP_MaterialMain.DiagramCode, MRP_MaterialMain.Weight,View_ProductSize_List.DisplayText FROM MRP_MaterialMain Left JOIN View_ProductSize_List ON MRP_MaterialMain.SizeType = View_ProductSize_List.ID WHERE (MRP_MaterialMain.MType = 5)";
            //DataSet ds = db.ExecuteDataSet(CommandType.Text, sSQL);
            //string outHTML = GetPriceInfo(0, 0);
            //this.priceInfo.InnerHtml = outHTML.ToString();
        }
        if (!string.IsNullOrEmpty(Request["ID"]))
        {
            //if(Request["StartDate"]==null)
            //    Request["StartDate"]="";
            //if (Request["EndDate"] == null)
            //    Request["EndDate"] = "";
            //if (!string.IsNullOrEmpty(Request["StartDate"]))
            {
                Session["dbWhereDetailsInSession"] = MRPUtility.buildDateCondition("DeliveryDate", Request["StartDate"], Request["EndDate"]);
                BillStartDate.Text=Request["StartDate"];
                BillEndDate.Text = Request["EndDate"];
                UIServer1.Visible = true;
            }
        }
    }
    protected void btnViewOrderBill_Click(object sender, EventArgs e)
    {
        string sWhere = string.Empty;
        //检查输入的项
        Response.Redirect(string.Format(@"MRP_ViewOrderBill.aspx?MODE=view&ID={0}&StartDate={1}&EndDate={2}", DropDownList1.SelectedValue, BillStartDate.Text,BillEndDate.Text));
        
    }

 
}
